package org.suyisen.feng.gateway.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.suyisen.feng.gateway.dto.CifuserDto;
import org.suyisen.feng.gateway.micro.core.CifuserMicroService;
import org.suyisen.feng.gateway.micro.core.ReactiveCifuserMicroService;
import org.suyisen.feng.gateway.route.impl.DynamicRouteServiceImpl;

import reactor.core.publisher.Mono;

/**
 * 
 */
@RestController
@RequestMapping("/gateway")
public class CifuserGatewayController {

	@Autowired
	private ReactiveCifuserMicroService cifuserMicroService;
	
	@Autowired
	private CifuserMicroService cifuserMicroService2;
	
	@Autowired
	private DynamicRouteServiceImpl service;
	
	
	@GetMapping("/qycifuser")
	public Mono<List<CifuserDto>> getCifuserInfo() {
	    return cifuserMicroService.getCifuserInfo();
	}
	
	
	@GetMapping("/qycifuser2")
	public Mono<List<CifuserDto>> getCifuserInfo2() {
	    return cifuserMicroService2.getCifuserInfo();
	}
	
	@GetMapping("/qyonecifuser")
	public Mono<CifuserDto> getTheOnecifuser() {
		return cifuserMicroService.getTheOneCifuserInfo();
	}
	
	 @GetMapping("/hello")
     public Mono<String> hello() {   
		 System.out.println(service.get().subscribe(value->{
			 System.out.println("------"+value);
		 }));
         return Mono.just("Welcome to reactive world ~"); 
     }

}
